Updated March 11, 2024.

North

Rock Creek at Owens River

Pleasant Valley Reservoir outflow

Bishop Creek total flow

Central

Big Pine Creek

Fish Springs at Railroad

Owens River below Big Pine Creek

South

Tinemaha Res Outflow

Lone Pine Creek at USGS

LA Aqueduct at Alabama Gates

Data

---
title: "Payahunaduu Streamflow"
output: 
  flexdashboard::flex_dashboard:
    storyboard: true
    source_code: embed
---

```{r setup, include=FALSE}

library(flexdashboard)
library(tidyverse)
library(lubridate)
library(hms)
library(glue)
library(plotly)
library(DT)
library(crosstalk)

streamflow2 <- read_csv("C:/Users/envir/Documents/106/Streamflow/LADWP_Webscraping/streamflow2.csv", 
                       col_types = cols(Streamflow_CFS = col_number(), 
                                        DateTime = col_datetime())) %>%
  mutate(Date = as.Date(DateTime)) %>%
  group_by(Site, Date) %>%
  summarise(CFS = mean(Streamflow_CFS))

streamflow2$CFS <- round(streamflow2$CFS, 1) 


raw <- read_csv("C:/Users/envir/Documents/106/Streamflow/LADWP_Webscraping/streamflow2.csv", 
                       col_types = cols(Streamflow_CFS = col_number(), 
                                        DateTime = col_datetime()))

```

Updated `r format(Sys.time(), '%B %d, %Y')`.

North
=======================================================================


### **Rock Creek** at Owens River

```{r}

RockCreek <- ggplot(data = filter(streamflow2, Site == "RockCreek" ), aes(x = Date, y = CFS)) +
  geom_line(color = "blue") +
  theme_bw(base_size=13) +
  labs( x = NULL, y = "FLow CFS", title = NULL) +
  scale_x_date() 

ggplotly(RockCreek)

```

### **Pleasant Valley Reservoir** outflow

```{r}

PVOut <- ggplot(data = filter(streamflow2, Site == "PleasantValleyOutflow" ), aes(x = Date, y = CFS)) +
  geom_line(color = "blue") +
  theme_bw(base_size=13) +
  labs( x = NULL, y = "FLow CFS", title = NULL) +
  scale_x_date() 

ggplotly(PVOut)

```

### **Bishop Creek** total flow

```{r}

BishopAll <- ggplot(data = filter(streamflow2, Site == "BishopCreeKTotal"), aes(x = Date, y = CFS)) +
  geom_line(color = "blue") +
  theme_bw(base_size=13) +
  labs( x = NULL, y = "FLow CFS", title = NULL) +
  scale_x_date() 

ggplotly(BishopAll)

```

Central
=======================================================================

### **Big Pine Creek**

```{r}

BPCreek <- ggplot(data = filter(streamflow2, Site == "BigPineCreek" ), aes(x = Date, y = CFS)) +
  geom_line(color = "blue") +
  theme_bw(base_size=13) +
  labs( x = NULL, y = "FLow CFS", title = NULL) +
  scale_x_date() 

ggplotly(BPCreek)

```

### **Fish Springs** at Railroad

```{r}

FishSprings <- ggplot(data = filter(streamflow2, Site == "FishSprings"), aes(x = Date, y = CFS)) +
  geom_line(color = "blue") +
  theme_bw(base_size=13) +
  labs( x = NULL, y = "FLow CFS", title = NULL) +
  scale_x_date() 

ggplotly(FishSprings)

```

### **Owens River** below Big Pine Creek

```{r}

OwensRiver <- ggplot(data = filter(streamflow2, Site == "OwensRiverBelowBPC" ), aes(x = Date, y = CFS)) +
  geom_line(color = "blue") +
  theme_bw(base_size=13) +
  labs( x = NULL, y = "FLow CFS", title = NULL) +
  scale_x_date() 

ggplotly(OwensRiver)

```

South
=======================================================================

### **Tinemaha Res** Outflow

```{r}

TinemahaResOutflow <- ggplot(data = filter(streamflow2, Site == "TinemahaResOutflow" ), aes(x = Date, y = CFS)) +
  geom_line(color = "blue") +
  theme_bw(base_size=13) +
  labs( x = NULL, y = "FLow CFS", title = NULL) +
  scale_x_date() 

ggplotly(TinemahaResOutflow)

```

### **Lone Pine Creek** at USGS

```{r}

LonePineCreek <- ggplot(data = filter(streamflow2, Site == "LonePineCreek"), aes(x = Date, y = CFS)) +
  geom_line(color = "blue") +
  theme_bw(base_size=13) +
  labs( x = NULL, y = "FLow CFS", title = NULL) +
  scale_x_date() 

ggplotly(LonePineCreek)

```

### **LA Aqueduct** at Alabama Gates

```{r}

LAAAlabamaGates<- ggplot(data = filter(streamflow2, Site == "LAAAlabamaGates" ), aes(x = Date, y = CFS)) +
  geom_line(color = "blue") +
  theme_bw(base_size=13) +
  labs( x = NULL, y = "FLow CFS", title = NULL) +
  scale_x_date() 

ggplotly(LAAAlabamaGates)

```

Data
=======================================================================

```{r filters}

cleaned <- raw %>%
  mutate(Site = case_when(
    Site == "RockCreek" ~ "Rock Creek", 
    Site == "PleasantValleyOutflow" ~ "PV Dam Outflow",
    Site == "BishopCreekThru" ~ "Bishop Creek Through Powerplant",
    Site == "BishopCreekAround" ~ "Bishop Creek Around Powerplant",
    Site == "BakerCreek" ~ "Baker Creek",
    Site == "BigPineCreek" ~ "Big Pine Creek",
    Site == "FishSprings" ~ "Fish Springs", 
    Site == "OwensRiverBelowBPC" ~ "Owens River Below Big Pine",
    Site == "TinemahaResOutflow" ~ "Tinemaha Res Outflow",
    Site == "IndependenceCreek" ~ "Independence Creek",
    Site == "LonePineCreek" ~ "Lone Pine Creek",
    Site == "CottonwoodCreek" ~ "Cottonwood Creek",
    Site == "LAAAlabamaGates" ~ "LA Aqueduct Alabama Gates",
    Site == "LAACottonwoodGates" ~ "LA Aqueduct Cottonwood Gates",
    Site == "LAACottonwoodGates" ~ "LA Aqueduct Cottonwood Gates",
    Site == "BishopCreeKTotal" ~ "Bishop Creek Total Flow", 
    TRUE ~ Site
  )) %>%
  mutate(Date = as.Date(DateTime)) %>%
  mutate(Time = format(DateTime, format = "%H:%M:%S")) %>%
  select(-DateTime)




sd <- SharedData$new(cleaned)


filter_checkbox(
    id = "raw", 
    label = "Site", 
    sharedData = sd, 
    group = ~Site, 
    inline = TRUE
  )



```




```{r}

Streamflow_table <- datatable(sd, extensions = c( "Buttons", "Scroller"),
              filter = 'top', 
              rownames = FALSE,
              width = "100%", 
              style = "bootstrap",
                            options = list (dom = 'Blrtip',
                              searchHighlight = FALSE,
                              buttons = c('copy','csv','excel','print'),
                              scrollCollapse = FALSE
                                    ), 
              class = c('compact cell-border stripe hover'))
Streamflow_table

```